
package util;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class JPAUtil {
    
    private static EntityManagerFactory emf = null;
    
    public static EntityManager getEntityManager() {
    
            if (emf == null) {
                emf = Persistence.createEntityManagerFactory("Projeto_CkeckList_-__Ederson_PU");
            }
            return emf.createEntityManager();
}
    
    public static void closeEntityManager (EntityManager em){
        
        try {
            em.close();
        } catch (Exception ex) {
            Logger.getLogger("Logger").log(Level.WARNING, "Problema na hora de fechar um Entitymanager: {0}", ex.getMessage());
        }
    }
}
